package cn.like.satoken.intersecpter;

import cn.like.satoken.token.TokenHelper;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author like 980650920@qq.com
 * @date 2021/7/16 10:07
 */
@Component
@Slf4j
public class FeignInterceptor implements RequestInterceptor {

    public void apply(RequestTemplate requestTemplate) {
        log.info("[ open feign ] path:{}",requestTemplate.path());

        // 为feign 设置 token请求信息
        requestTemplate.header(TokenHelper.tokenName(), TokenHelper.token());
    }
}
